package com.ai.aicodeinghelper.tools;

import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

/**
 * tools 工具类
 * 获取当前时区时间
 */
@Slf4j
public class TimeTools {

    @Tool(description = "获取当前时区时间")
    public String getTimeByZoneId(@ToolParam(description = "时区id")String zoneId){
        ZoneId zid = ZoneId.of(zoneId);
        log.info("zoneId: {}", zoneId);
        ZonedDateTime now = ZonedDateTime.now(zid);
        log.info("now: {}", now);
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        log.info("dateTimeFormatter: {}", dateTimeFormatter);
        return now.format(dateTimeFormatter);
    }
}
